package com.ruoyi.web.controller.product;
import com.ruoyi.common.annotation.Anonymous;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.product.domain.Product;
import com.ruoyi.product.service.ProductService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
//23201012827 -魏巍
@Anonymous
@Api(tags = "饮品管理")
@RestController
@Controller
public class ProductController {
    @Autowired
    ProductService service;
    //查询饮品列表
    @ApiOperation(value = "饮品列表查询")
    @PostMapping("/GetProductList")
    public AjaxResult GetProductList(@RequestBody Product p){
        return AjaxResult.success(service.getProductList(p));
    }
    //新增饮品
    @ApiOperation("新增饮品")
    @PostMapping("/addProduct")
    public AjaxResult addProduct(@RequestBody Product p){
        int result = service.addProduct(p);
        return AjaxResult.success(result);
    }

    //修改 23201012827魏巍
    @ApiOperation(value = "修改饮品")
    @PostMapping("/UpdateProduct")
    public AjaxResult UpdateStudent(@RequestBody Product p){
        return  AjaxResult.success(service.updateProduct(p));
    }

    //删除饮品 23201012827魏巍
    @ApiOperation(value = "删除饮品")
    @GetMapping("/DeteleProduct")
    public AjaxResult DeleteStudent(int id){
        return  AjaxResult.success(service.deleteProduct(id));
    }


}
